package org.feng.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.feng.mapper.SysDeptMapper;
import org.feng.service.ISysDeptService;
import org.feng.entity.SysDept;
import org.springframework.stereotype.Service;
import org.feng.base.service.impl.BaseServiceImpl;

import java.util.List;

/**
 * 部门表 服务实现类
 *
 * @author : FengShuai
 * @since : 2024/6/27 9:24
 */
@Service
public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {

    @Override
    public void getStudentDeptId(String deptId, List<String> list) {
        if (!list.contains(deptId)) {
            list.add(deptId);
        }
        List<SysDept> deptList = this.list(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getParentId, deptId));
        for (SysDept sysDept : deptList) {
            list.add(sysDept.getId());
            getStudentDeptId(sysDept.getId(), list);
        }
    }
}

